home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Gobby 0.4.7 / gobby-0.4.7.exe / {app} / share / gtksourceview-2.0 / language-specs / perl.lang < prev    next >
Extensible Markup Language  |  2008-09-09  |  36KB  |  1,018 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- ex:set ts=2 et:
  3.  
  4.  Copyright (C) 2006, 2007 Steve Fr├⌐cinaux <code@istique.net>
  5.  
  6.  This library is free software; you can redistribute it and/or
  7.  modify it under the terms of the GNU Library General Public
  8.  License as published by the Free Software Foundation; either
  9.  version 2 of the License, or (at your option) any later version.
  10.  
  11.  This library is distributed in the hope that it will be useful,
  12.  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  Library General Public License for more details.
  15.  
  16.  You should have received a copy of the GNU Library General Public
  17.  License along with this library; if not, write to the
  18.  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.  Boston, MA 02111-1307, USA.
  20.  
  21. TODO: extended regex support
  22. FIXME: =pod should require an empty line before/after, as written in perlpod
  23.  
  24. -->
  25. <language id="perl" _name="Perl" version="2.0" _section="Scripts">
  26.   <metadata>
  27.     <property name="mimetypes">text/x-perl;application/x-perl</property>
  28.     <property name="globs">*.pl;*.pm;*.al;*.perl</property>
  29.     <property name="line-comment-start">#</property>
  30.   </metadata>
  31.  
  32.   <styles>
  33.     <style id="comment"           _name="Comment"            map-to="def:comment"/>
  34.     <style id="line-directive"    _name="Line Directive"     map-to="def:preprocessor"/>
  35.     <style id="include-statement" _name="Include Statement"  map-to="def:preprocessor"/>
  36.     <style id="string"            _name="String"             map-to="def:string"/>
  37.     <style id="keyword"           _name="Keyword"            map-to="def:keyword"/>
  38.     <style id="builtin"           _name="Builtin Function"   map-to="def:builtin"/>
  39.     <style id="here-doc"          _name="Heredoc"            map-to="def:string" />
  40.     <style id="here-doc-bound"    _name="Heredoc Bound"      map-to="def:string"/>
  41.     <style id="system-command"    _name="System Command"     map-to="def:string"/>
  42.     <style id="operator"          _name="Operator"           map-to="def:keyword"/>
  43.     <style id="variable"          _name="Variable"           map-to="def:type"/>
  44.     <style id="file-descriptor"   _name="File Descriptor"    map-to="def:special-constant"/>
  45.     <style id="control"           _name="Control"            map-to="def:preprocessor"/>
  46.     <style id="regex"             _name="Regular Expression" map-to="def:string"/>
  47.     <style id="error"             _name="Error"              map-to="def:error"/>
  48.     <style id="pod"               _name="POD"                map-to="def:comment"/>
  49.     <style id="pod-escape"        _name="POD Escape"         map-to="def:special-char"/>
  50.     <style id="pod-keyword"       _name="POD keyword"        map-to="def:keyword"/>
  51.     <style id="pod-heading"       _name="POD heading"        map-to="def:doc-comment-element"/>
  52.   </styles>
  53.  
  54.   <definitions>
  55.     <context id="perl">
  56.       <include>
  57.         <context ref="def:shebang"/>
  58.         <context ref="line-directive"/>
  59.         <context ref="def:shell-like-comment"/>
  60.         <context ref="pod"/>
  61.         <context ref="data"/>
  62.  
  63.         <context ref="double-quoted-string"/>
  64.         <context ref="single-quoted-string"/>
  65.         <context ref="system-command"/>
  66.         <context ref="word-list"/>
  67.         <context ref="regular-expression"/>
  68.         <context ref="match"/>
  69.         <context ref="substitution"/>
  70.         <context ref="transliteration"/>
  71.  
  72.         <context ref="match-slashslash"/>
  73.  
  74.         <context ref="here-doc-no-ve"/>
  75.         <context ref="here-doc"/>
  76.  
  77.         <context ref="sub"/>
  78.         <context ref="variable"/>
  79.         <context ref="include-statement"/>
  80.         <context ref="operator"/>
  81.         <context ref="keyword"/>
  82.         <context ref="control"/>
  83.         <context ref="file-descriptor"/>
  84.         <context ref="builtin"/>
  85.       </include>
  86.     </context>
  87.  
  88.     <!-- in case we have an obviously wrong piece of code to highlight.
  89.          We put it last so it can highlight everything not handled yet. -->
  90.     <context id="error" style-ref="error" extend-parent="false">
  91.       <match>\S</match>
  92.     </context>
  93.  
  94.     <define-regex id="operator" extended="true">
  95.       \-> |
  96.       \+\+ | \-\- |
  97.       \*\* |
  98.       \! | \~ | \\ | \+ | \- |
  99.       [!=]\~ |
  100.       \* | / | % |
  101.       << | >> |
  102.       < | > | [<>=!]= | <=> |
  103.       & | \| | \^ |
  104.       && |
  105.       \.\. | \.\.\. |
  106.       \? | : |
  107.       = | \*\*= | \+= | \*= | &= | <<= | &&= | \-= | /= |
  108.       \|= | >>= | \|\|= | \.= | %= | \^= | \bx= |
  109.       => |
  110.       \b(x|lt|gt|le|ge|eq|ne|cmp|not|and|or|xor)\b
  111.     </define-regex>
  112.  
  113.     <context id="operator" style-ref="operator"><!-- see `man perlop` -->
  114.       <match>\%{operator}</match>
  115.     </context>
  116.  
  117.     <!-- #### VARIABLES ################################################### -->
  118.  
  119.     <!-- $ is not defined in this regexp because it would conflict with
  120.          \%{plain-variable}. $ is the current module. -->
  121.     <define-regex id="special-variable" extended="true">
  122.       \$^[ADEFHILMOPSTWX]? |                                  # ($^A, ...)
  123.       \$[\\\"\[\]'&`+*.,;=%~?@$><\(|/!-] |     # ($|, $', ...)
  124.       \$:[^:] |            # avoid confusion with $::foo (equiv. to $main::foo)
  125.       \$(0|[1-9][0-9]*)    # numbered variables (regex matches)
  126.     </define-regex>
  127.  
  128.     <define-regex id="plain-variable" extended="true">
  129.       ([$@%]|\$\#)\$*[a-zA-Z_][a-zA-Z0-9_]*
  130.     </define-regex>
  131.  
  132.     <context id="plain-variable">
  133.       <include>
  134.         <context style-ref="variable">
  135.           <start>[$@%]{</start>
  136.           <end>}</end>
  137.         </context>
  138.         <context style-ref="variable">
  139.           <match>\%{plain-variable}</match>
  140.         </context>
  141.       </include>
  142.     </context>
  143.  
  144.     <context id="special-variable" style-ref="variable">
  145.       <match>\%{special-variable}</match>
  146.     </context>
  147.  
  148.     <context id="variable">
  149.       <include>
  150.         <context ref="plain-variable"/>
  151.         <context ref="special-variable"/>
  152.       </include>
  153.     </context>
  154.  
  155.     <!-- #### PATTERNS / STRINGS / REGEX ################################## -->
  156.     <!-- see `man perlop` -->
  157.  
  158.     <!-- available delimiters for m// or s///-style patterns (probably not
  159.          complete yet).                                                     -->
  160.     <define-regex id="pattern-delimiter" extended="true">
  161.       [&+|!/@#\^\-=:;,.?*\\%`"']
  162.     </define-regex>
  163.  
  164.     <!-- this assertion is shared by all the regex contexts to avoid wrong
  165.          highlighing of function calls, etc.
  166.          \b can't be used because of $var, @var, &func, %func.              -->
  167.     <!-- FIXME I added { and ( to the list to fix #507075 and #535703. Someone
  168.          please look at it, it seems wrong. It probably should be a positive
  169.          look-behind. -->
  170.     <define-regex id="pattern-before" extended="true">
  171.       (?<![a-zA-Z0-9@%{(])
  172.     </define-regex>
  173.  
  174.     <context id="in-pattern">
  175.       <include>
  176.         <context ref="def:escape"/>
  177.         <context ref="plain-variable"/>
  178.         <context extend-parent="false">
  179.           <start>(?=\$)</start>
  180.           <include>
  181.             <!-- some variables are not recognized in patterns -->
  182.             <context><match>\$(?=[|)])</match></context>
  183.             <context ref="special-variable"/>
  184.           </include>
  185.         </context>
  186.       </include>
  187.     </context>
  188.  
  189.  
  190.     <!-- The following context definitions are there to handle nesting of
  191.          brackets in bracket-delimited regexes.                             -->
  192.  
  193.     <context id="in-pattern-curly-no-ve">
  194.       <include>
  195.         <context>
  196.           <start>{</start><end>}</end>
  197.           <include><context ref="in-pattern-curly-no-ve"/></include>
  198.         </context>
  199.       </include>
  200.     </context>
  201.  
  202.     <context id="in-pattern-curly">
  203.       <include>
  204.         <context>
  205.           <start>{</start><end>}</end>
  206.           <include><context ref="in-pattern-curly"/></include>
  207.         </context>
  208.         <context ref="in-pattern"/>
  209.       </include>
  210.     </context>
  211.  
  212.     <context id="in-pattern-square-no-ve">
  213.       <include>
  214.         <context>
  215.           <start>\[</start><end>\]</end>
  216.           <include><context ref="in-pattern-square-no-ve"/></include>
  217.         </context>
  218.       </include>
  219.     </context>
  220.  
  221.     <context id="in-pattern-square">
  222.       <include>
  223.         <context>
  224.           <start>\[</start><end>\]</end>
  225.           <include><context ref="in-pattern-square"/></include>
  226.         </context>
  227.         <context ref="in-pattern"/>
  228.       </include>
  229.     </context>
  230.  
  231.     <context id="in-pattern-round-no-ve">
  232.       <include>
  233.         <context>
  234.           <start>\(</start><end>}</end>
  235.           <include><context ref="in-pattern-round-no-ve"/></include>
  236.         </context>
  237.       </include>
  238.     </context>
  239.  
  240.     <context id="in-pattern-round">
  241.       <include>
  242.         <context>
  243.           <start>\(</start><end>\)</end>
  244.           <include><context ref="in-pattern-round"/></include>
  245.         </context>
  246.         <context ref="in-pattern"/>
  247.       </include>
  248.     </context>
  249.  
  250.     <context id="in-pattern-angle-no-ve">
  251.       <include>
  252.         <context>
  253.           <start><</start><end>></end>
  254.           <include><context ref="in-pattern-angle-no-ve"/></include>
  255.         </context>
  256.       </include>
  257.     </context>
  258.  
  259.     <context id="in-pattern-angle">
  260.       <include>
  261.         <context>
  262.           <start><</start><end>></end>
  263.           <include><context ref="in-pattern-angle"/></include>
  264.         </context>
  265.         <context ref="in-pattern"/>
  266.       </include>
  267.     </context>
  268.  
  269.     <!-- One level higher: the following contexts define single and double
  270.          patterns in general, in ve and no-ve version.                      -->
  271.  
  272.     <define-regex id="end-of-pattern" extended="true">
  273.       (?<=
  274.           [}\]\)>]|
  275.           \%{pattern-delimiter}
  276.       )
  277.     </define-regex>
  278.  
  279.     <context id="simple-pattern" once-only="true">
  280.       <start/>
  281.       <include>
  282.         <context ref="asserted-comment"/>
  283.         <context end-parent="true">
  284.           <start>{</start><end>}</end>
  285.           <include><context ref="in-pattern-curly"/></include>
  286.         </context>
  287.         <context end-parent="true">
  288.           <start>\[</start><end>\]</end>
  289.           <include><context ref="in-pattern-square"/></include>
  290.         </context>
  291.         <context end-parent="true">
  292.           <start>\(</start><end>\)</end>
  293.           <include><context ref="in-pattern-round"/></include>
  294.         </context>
  295.         <context end-parent="true">
  296.           <start><</start><end>></end>
  297.           <include><context ref="in-pattern-angle"/></include>
  298.         </context>
  299.         <context end-parent="true">
  300.           <!-- '' doesn't usually have var expansion. -->
  301.           <start>'</start><end>'</end>
  302.           <include>
  303.             <context style-ref="def:special-char">
  304.               <match>\\\\|\\'</match>
  305.             </context>
  306.           </include>
  307.         </context>
  308.         <context end-parent="true">
  309.           <start>(?P<RD>\%{pattern-delimiter})</start>
  310.           <end>\%{RD@start}</end>
  311.           <include><context ref="in-pattern"/></include>
  312.         </context>
  313.         <context ref="asserted-comment"/>
  314.         <context ref="error"/>
  315.       </include>
  316.     </context>
  317.  
  318.     <context id="simple-pattern-no-ve" once-only="true">
  319.       <start/>
  320.       <include>
  321.         <context end-parent="true">
  322.           <start>{</start><end>}</end>
  323.           <include><context ref="in-pattern-curly-no-ve"/></include>
  324.         </context>
  325.         <context end-parent="true">
  326.           <start>\[</start><end>\]</end>
  327.           <include><context ref="in-pattern-square-no-ve"/></include>
  328.         </context>
  329.         <context end-parent="true">
  330.           <start>\(</start><end>\)</end>
  331.           <include><context ref="in-pattern-round-no-ve"/></include>
  332.         </context>
  333.         <context end-parent="true">
  334.           <start><</start><end>></end>
  335.           <include><context ref="in-pattern-angle-no-ve"/></include>
  336.         </context>
  337.         <context end-parent="true">
  338.           <start>(?P<RD>\%{pattern-delimiter})</start>
  339.           <end>\%{RD@start}</end>
  340.         </context>
  341.         <context ref="asserted-comment"/>
  342.         <context ref="error"/>
  343.       </include>
  344.     </context>
  345.  
  346.     <context id="double-pattern" once-only="true">
  347.       <start/>
  348.       <include>
  349.         <context end-parent="true">
  350.           <start>'</start>
  351.           <end>'</end>
  352.           <include>
  353.             <context once-only="true">
  354.               <start>(?<=(?P<RD>.))</start>
  355.               <end>\%{RD@start}</end>
  356.             </context>
  357.           </include>
  358.         </context>
  359.         <context end-parent="true">
  360.           <start>(?P<RD>\%{pattern-delimiter})</start>
  361.           <end>\%{RD@start}</end>
  362.           <include>
  363.             <context once-only="true">
  364.               <start>(?<=(?P<RD>.))</start>
  365.               <end>\%{RD@start}</end>
  366.               <include><context ref="in-pattern"/></include>
  367.             </context>
  368.             <context ref="in-pattern"/>
  369.           </include>
  370.         </context>
  371.         <context end-parent="true">
  372.           <start/>
  373.           <include>
  374.             <context ref="simple-pattern"/>
  375.             <!-- quick hack to include the same pattern twice: we surround it
  376.                  with a house-keeping context -->
  377.             <context once-only="true" end-parent="true">
  378.               <start>\%{end-of-pattern}</start>
  379.               <end>\%{end-of-pattern}</end>
  380.               <include><context ref="simple-pattern"/></include>
  381.             </context>
  382.           </include>
  383.         </context>
  384.       </include>
  385.     </context>
  386.  
  387.     <context id="double-pattern-no-ve" once-only="true">
  388.       <start/>
  389.       <include>
  390.         <context end-parent="true">
  391.           <start>(?P<RD>\%{pattern-delimiter})</start>
  392.           <end>\%{RD@start}</end>
  393.           <include>
  394.             <context once-only="true">
  395.               <start>(?<=(?P<RD>.))</start>
  396.               <end>\%{RD@start}</end>
  397.             </context>
  398.           </include>
  399.         </context>
  400.         <context end-parent="true">
  401.           <start/>
  402.           <include>
  403.             <context ref="simple-pattern-no-ve"/>
  404.             <context once-only="true" end-parent="true">
  405.               <start>\%{end-of-pattern}</start>
  406.               <end>\%{end-of-pattern}</end>
  407.               <include><context ref="simple-pattern-no-ve"/></include>
  408.             </context>
  409.           </include>
  410.         </context>
  411.       </include>
  412.     </context>
  413.  
  414.     <context id="single-quoted-string">
  415.       <include>
  416.         <context style-ref="string">
  417.           <start>'</start><end>'</end>
  418.           <include>
  419.             <context style-ref="def:special-char">
  420.               <match>\\\\|\\'</match>
  421.             </context>
  422.           </include>
  423.         </context>
  424.         <context style-ref="string">
  425.           <start>\%{pattern-before}q\b</start>
  426.           <end>\%{end-of-pattern}</end>
  427.           <include><context ref="simple-pattern-no-ve"/></include>
  428.         </context>
  429.       </include>
  430.     </context>
  431.  
  432.     <context id="double-quoted-string">
  433.       <include>
  434.         <context style-ref="string">
  435.           <start>"</start><end>"</end>
  436.           <include><context ref="in-pattern"/></include>
  437.         </context>
  438.         <context style-ref="string">
  439.           <start>\%{pattern-before}qq\b</start>
  440.           <end>\%{end-of-pattern}</end>
  441.           <include>
  442.             <context ref="asserted-comment"/>
  443.             <!-- qq'' *has* var expansion, so we can't just use
  444.                  <context ref="single-pattern"/>.                           -->
  445.             <context end-parent="true">
  446.               <start>{</start><end>}</end>
  447.               <include><context ref="in-pattern-curly"/></include>
  448.             </context>
  449.             <context end-parent="true">
  450.               <start>\[</start><end>\]</end>
  451.               <include><context ref="in-pattern-square"/></include>
  452.             </context>
  453.             <context end-parent="true">
  454.               <start>\(</start><end>\)</end>
  455.               <include><context ref="in-pattern-round"/></include>
  456.             </context>
  457.             <context end-parent="true">
  458.               <start><</start><end>></end>
  459.               <include><context ref="in-pattern-angle"/></include>
  460.             </context>
  461.             <context end-parent="true">
  462.               <start>(?P<RD>\%{pattern-delimiter})</start>
  463.               <end>\%{RD@start}</end>
  464.               <include><context ref="in-pattern"/></include>
  465.             </context>
  466.             <context ref="error"/>
  467.           </include>
  468.         </context>
  469.       </include>
  470.     </context>
  471.  
  472.     <context id="word-list" style-ref="string">
  473.       <start>\%{pattern-before}qw\b</start>
  474.       <end>\%{end-of-pattern}</end>
  475.       <include><context ref="simple-pattern-no-ve"/></include>
  476.     </context>
  477.  
  478.     <context id="regular-expression" style-ref="regex">
  479.       <start>\%{pattern-before}qr\b</start>
  480.       <end>\%{end-of-pattern}[imosx]*</end>
  481.       <include><context ref="simple-pattern"/></include>
  482.     </context>
  483.  
  484.     <context id="system-command">
  485.       <include>
  486.         <context style-ref="system-command">
  487.           <start>`</start><end>`</end>
  488.           <include><context ref="in-pattern"/></include>
  489.         </context>
  490.         <context style-ref="system-command">
  491.           <start>\%{pattern-before}qx\b</start>
  492.           <end>\%{end-of-pattern}</end>
  493.           <include><context ref="simple-pattern"/></include>
  494.         </context>
  495.       </include>
  496.     </context>
  497.  
  498.     <context id="match" style-ref="regex">
  499.       <start>\%{pattern-before}m\b</start>
  500.       <end>\%{end-of-pattern}[cgimosx]*</end>
  501.       <include><context ref="simple-pattern"/></include>
  502.     </context>
  503.  
  504.     <context id="substitution" style-ref="regex">
  505.       <start>\%{pattern-before}s\b</start>
  506.       <end>\%{end-of-pattern}[ecgimosx]*</end>
  507.       <include><context ref="double-pattern"/></include>
  508.     </context>
  509.  
  510.     <context id="transliteration" style-ref="regex">
  511.       <start>\%{pattern-before}(tr|y)\b</start>
  512.       <end>\%{end-of-pattern}[cds]*</end>
  513.       <include><context ref="double-pattern-no-ve"/></include>
  514.     </context>
  515.  
  516.     <!-- hacks, mostly taken from vim's perl.vim. As they say:
  517.          ΓÇ£Below some hacks to recognise the // variant. This is virtually
  518.           impossible to catch in all cases as the / is used in so many other
  519.           ways, but these should be the most obvious ones.ΓÇ¥ -->
  520.     <context id="match-slashslash">
  521.       <include>
  522.         <context style-inside="true" style-ref="regex">
  523.           <start>(^|[^$@%&])(split|while|if)\s+(/)</start>
  524.           <end>/[cgimosx]*</end>
  525.           <include>
  526.             <context sub-pattern="2" where="start" style-ref="builtin"/>
  527.             <context sub-pattern="3" where="start" style-ref="regex"/>
  528.             <context sub-pattern="0" where="end" style-ref="regex"/>
  529.             <context ref="in-pattern"/>
  530.           </include>
  531.         </context>
  532.         <context style-inside="true" style-ref="regex">
  533.           <start>(^|(?<=[\(\{]))\s*(/)</start>
  534.           <end>/[cgimosx]*</end>
  535.           <include>
  536.             <context sub-pattern="2" where="start" style-ref="regex"/>
  537.             <context sub-pattern="0" where="end" style-ref="regex"/>
  538.             <context ref="in-pattern"/>
  539.           </include>
  540.         </context>
  541.         <context style-inside="true" style-ref="regex">
  542.           <start>\%{operator}\s*(/)</start>
  543.           <end>/[cgimosx]*</end>
  544.           <include>
  545.             <context sub-pattern="1" where="start" style-ref="operator"/>
  546.             <context sub-pattern="2" where="start" style-ref="regex"/>
  547.             <context sub-pattern="0" where="end" style-ref="regex"/>
  548.             <context ref="in-pattern"/>
  549.           </include>
  550.         </context>
  551.       </include>
  552.     </context>
  553.  
  554.     <!-- #### HEREDOC STRINGS ############################################# -->
  555.  
  556.     <define-regex id="here-doc-bound-char">[^\s'"=;]</define-regex>
  557.  
  558.     <context id="here-doc-no-ve">
  559.       <start><<\'(?P<HDB>\%{here-doc-bound-char}*)\'</start>
  560.       <end>^\%{HDB@start}$</end>
  561.       <include>
  562.         <context sub-pattern="0" where="start" style-ref="here-doc-bound"/>
  563.         <context sub-pattern="0" where="end" style-ref="here-doc-bound"/>
  564.         <context once-only="true" end-at-line-end="true">
  565.           <start/><include><context ref="perl"/></include>
  566.         </context>
  567.         <context style-ref="here-doc" extend-parent="false"><start/></context>
  568.       </include>
  569.     </context>
  570.  
  571.     <context id="here-doc">
  572.       <start extended="true" dupnames="true">
  573.         <<
  574.         (
  575.           \"(?P<HDB>\%{here-doc-bound-char}*)\"|   # "EOF"
  576.           (?P<HDB>\%{here-doc-bound-char}*)        # EOF
  577.         )
  578.       </start>
  579.       <end>^\%{HDB@start}$</end>
  580.       <include>
  581.         <context sub-pattern="0" where="start" style-ref="here-doc-bound"/>
  582.         <context sub-pattern="0" where="end" style-ref="here-doc-bound"/>
  583.         <context once-only="true" end-at-line-end="true">
  584.           <start/><include><context ref="perl"/></include>
  585.         </context>
  586.         <context style-ref="here-doc" extend-parent="false">
  587.           <start/>
  588.           <include>
  589.             <context ref="def:escape"/>
  590.             <context ref="variable"/>
  591.           </include>
  592.         </context>
  593.       </include>
  594.     </context>
  595.  
  596.     <!-- #### KEYWORDS / BUILTINS / ETC ################################### -->
  597.  
  598.     <define-regex id="function">[a-zA-Z_][a-zA-Z0-9_]*</define-regex>
  599.  
  600.     <!-- in sub context, everything is a function -->
  601.     <context id="sub">
  602.       <match>(sub)\s+\%{function}\b</match>
  603.       <include><context sub-pattern="1" style-ref="keyword"/></include>
  604.     </context>
  605.  
  606.     <context id="file-descriptor" style-ref="file-descriptor">
  607.       <keyword>STDIN</keyword>
  608.       <keyword>STDOUT</keyword>
  609.       <keyword>STDERR</keyword>
  610.     </context>
  611.  
  612.     <context id="control" style-ref="control">
  613.       <keyword>BEGIN</keyword>
  614.       <keyword>END</keyword>
  615.       <keyword>CHECK</keyword>
  616.       <keyword>INIT</keyword>
  617.     </context>
  618.  
  619.     <context id="include-statement">
  620.       <include>
  621.         <context style-ref="include-statement">
  622.           <keyword>require</keyword>
  623.         </context>
  624.         <context>
  625.           <!-- 'use' and 'no' can be used with special flags, so we try to
  626.                highlight them as well. -->
  627.           <start>(use|no)\s</start>
  628.           <end>;</end>
  629.           <include>
  630.             <context sub-pattern="0" where="start" style-ref="include-statement"/>
  631.             <context once-only="true" style-ref="include-statement">
  632.               <keyword>attributes</keyword>
  633.               <keyword>autouse</keyword>
  634.               <keyword>base</keyword>
  635.               <keyword>bigint</keyword>
  636.               <keyword>bignum</keyword>
  637.               <keyword>bigrat</keyword>
  638.               <keyword>blib</keyword>
  639.               <keyword>bytes</keyword>
  640.               <keyword>charnames</keyword>
  641.               <keyword>constant</keyword>
  642.               <keyword>diagnostics</keyword>
  643.               <keyword>encoding</keyword>
  644.               <keyword>fields</keyword>
  645.               <keyword>fileset</keyword>
  646.               <keyword>if</keyword>
  647.               <keyword>integer</keyword>
  648.               <keyword>less</keyword>
  649.               <keyword>lib</keyword>
  650.               <keyword>locale</keyword>
  651.               <keyword>open</keyword>
  652.               <keyword>ops</keyword>
  653.               <keyword>overload</keyword>
  654.               <keyword>re</keyword>
  655.               <keyword>sigtrap</keyword>
  656.               <keyword>sort</keyword>
  657.               <keyword>strict</keyword>
  658.               <keyword>subs</keyword>
  659.               <keyword>threads</keyword>
  660.               <keyword>threads::shared</keyword>
  661.               <keyword>utf8</keyword>
  662.               <keyword>vars</keyword>
  663.               <keyword>vmish</keyword>
  664.               <keyword>warnings</keyword>
  665.               <keyword>warnings::register</keyword>
  666.             </context>
  667.             <context ref="perl"/>
  668.           </include>
  669.         </context>
  670.       </include>
  671.     </context>
  672.  
  673.     <context id="keyword" style-ref="keyword">
  674.       <keyword>break</keyword>
  675.       <keyword>continue</keyword>
  676.       <keyword>do</keyword>
  677.       <keyword>each</keyword>
  678.       <keyword>else</keyword>
  679.       <keyword>elsif</keyword>
  680.       <keyword>foreach</keyword>
  681.       <keyword>for</keyword>
  682.       <keyword>if</keyword>
  683.       <keyword>last</keyword>
  684.       <keyword>local</keyword>
  685.       <keyword>my</keyword>
  686.       <keyword>next</keyword>
  687.       <keyword>our</keyword>
  688.       <keyword>package</keyword>
  689.       <keyword>return</keyword>
  690.       <keyword>sub</keyword>
  691.       <keyword>unless</keyword>
  692.       <keyword>until</keyword>
  693.       <keyword>while</keyword>
  694.       <keyword>__FILE__</keyword>
  695.       <keyword>__LINE__</keyword>
  696.       <keyword>__PACKAGE__</keyword>
  697.     </context>
  698.  
  699.     <context id="builtin" style-ref="builtin">
  700.       <!-- see `man perlfunc` -->
  701.       <keyword>abs</keyword>
  702.       <keyword>accept</keyword>
  703.       <keyword>alarm</keyword>
  704.       <keyword>atan2</keyword>
  705.       <keyword>bind</keyword>
  706.       <keyword>binmode</keyword>
  707.       <keyword>bless</keyword>
  708.       <keyword>caller</keyword>
  709.       <keyword>chdir</keyword>
  710.       <keyword>chmod</keyword>
  711.       <keyword>chomp</keyword>
  712.       <keyword>chop</keyword>
  713.       <keyword>chown</keyword>
  714.       <keyword>chr</keyword>
  715.       <keyword>chroot</keyword>
  716.       <keyword>closedir</keyword>
  717.       <keyword>close</keyword>
  718.       <keyword>connect</keyword>
  719.       <keyword>cos</keyword>
  720.       <keyword>crypt</keyword>
  721.       <keyword>dbmclose</keyword>
  722.       <keyword>dbmopen</keyword>
  723.       <keyword>defined</keyword>
  724.       <keyword>delete</keyword>
  725.       <keyword>die</keyword>
  726.       <keyword>dump</keyword>
  727.       <keyword>each</keyword>
  728.       <keyword>endgrent</keyword>
  729.       <keyword>endhostent</keyword>
  730.       <keyword>endnetent</keyword>
  731.       <keyword>endprotoent</keyword>
  732.       <keyword>endpwent</keyword>
  733.       <keyword>endservent</keyword>
  734.       <keyword>eof</keyword>
  735.       <keyword>eval</keyword>
  736.       <keyword>exec</keyword>
  737.       <keyword>exists</keyword>
  738.       <keyword>exit</keyword>
  739.       <keyword>exp</keyword>
  740.       <keyword>fcntl</keyword>
  741.       <keyword>fileno</keyword>
  742.       <keyword>flock</keyword>
  743.       <keyword>fork</keyword>
  744.       <keyword>format</keyword>
  745.       <keyword>formline</keyword>
  746.       <keyword>getc</keyword>
  747.       <keyword>getgrent</keyword>
  748.       <keyword>getgrgid</keyword>
  749.       <keyword>getgrnam</keyword>
  750.       <keyword>gethostbyaddr</keyword>
  751.       <keyword>gethostbyname</keyword>
  752.       <keyword>gethostent</keyword>
  753.       <keyword>getlogin</keyword>
  754.       <keyword>getnetbyaddr</keyword>
  755.       <keyword>getnetbyname</keyword>
  756.       <keyword>getnetent</keyword>
  757.       <keyword>getpeername</keyword>
  758.       <keyword>getpgrp</keyword>
  759.       <keyword>getppid</keyword>
  760.       <keyword>getpriority</keyword>
  761.       <keyword>getprotobyname</keyword>
  762.       <keyword>getprotobynumber</keyword>
  763.       <keyword>getprotoent</keyword>
  764.       <keyword>getpwent</keyword>
  765.       <keyword>getpwnam</keyword>
  766.       <keyword>getpwuid</keyword>
  767.       <keyword>getservbyname</keyword>
  768.       <keyword>getservbyport</keyword>
  769.       <keyword>getservent</keyword>
  770.       <keyword>getsockname</keyword>
  771.       <keyword>getsockopt</keyword>
  772.       <keyword>glob</keyword>
  773.       <keyword>gmtime</keyword>
  774.       <keyword>goto</keyword>
  775.       <keyword>grep</keyword>
  776.       <keyword>hex</keyword>
  777.       <keyword>import</keyword>
  778.       <keyword>index</keyword>
  779.       <keyword>int</keyword>
  780.       <keyword>ioctl</keyword>
  781.       <keyword>join</keyword>
  782.       <keyword>keys</keyword>
  783.       <keyword>kill</keyword>
  784.       <keyword>lcfirst</keyword>
  785.       <keyword>lc</keyword>
  786.       <keyword>length</keyword>
  787.       <keyword>link</keyword>
  788.       <keyword>listen</keyword>
  789.       <keyword>localtime</keyword>
  790.       <keyword>log</keyword>
  791.       <keyword>lstat</keyword>
  792.       <keyword>map</keyword>
  793.       <keyword>mkdir</keyword>
  794.       <keyword>msgctl</keyword>
  795.       <keyword>msgget</keyword>
  796.       <keyword>msgrcv</keyword>
  797.       <keyword>msgsnd</keyword>
  798.       <keyword>new</keyword>
  799.       <keyword>oct</keyword>
  800.       <keyword>opendir</keyword>
  801.       <keyword>open</keyword>
  802.       <keyword>ord</keyword>
  803.       <keyword>pack</keyword>
  804.       <keyword>pipe</keyword>
  805.       <keyword>pop</keyword>
  806.       <keyword>pos</keyword>
  807.       <keyword>printf</keyword>
  808.       <keyword>print</keyword>
  809.       <keyword>prototype</keyword>
  810.       <keyword>push</keyword>
  811.       <keyword>quotemeta</keyword>
  812.       <keyword>rand</keyword>
  813.       <keyword>readdir</keyword>
  814.       <keyword>read</keyword>
  815.       <keyword>readlink</keyword>
  816.       <keyword>recv</keyword>
  817.       <keyword>redo</keyword>
  818.       <keyword>ref</keyword>
  819.       <keyword>rename</keyword>
  820.       <keyword>reset</keyword>
  821.       <keyword>reverse</keyword>
  822.       <keyword>rewinddir</keyword>
  823.       <keyword>rindex</keyword>
  824.       <keyword>rmdir</keyword>
  825.       <keyword>scalar</keyword>
  826.       <keyword>seekdir</keyword>
  827.       <keyword>seek</keyword>
  828.       <keyword>select</keyword>
  829.       <keyword>semctl</keyword>
  830.       <keyword>semget</keyword>
  831.       <keyword>semop</keyword>
  832.       <keyword>send</keyword>
  833.       <keyword>setgrent</keyword>
  834.       <keyword>sethostent</keyword>
  835.       <keyword>setnetent</keyword>
  836.       <keyword>setpgrp</keyword>
  837.       <keyword>setpriority</keyword>
  838.       <keyword>setprotoent</keyword>
  839.       <keyword>setpwent</keyword>
  840.       <keyword>setservent</keyword>
  841.       <keyword>setsockopt</keyword>
  842.       <keyword>shift</keyword>
  843.       <keyword>shmctl</keyword>
  844.       <keyword>shmget</keyword>
  845.       <keyword>shmread</keyword>
  846.       <keyword>shmwrite</keyword>
  847.       <keyword>shutdown</keyword>
  848.       <keyword>sin</keyword>
  849.       <keyword>sleep</keyword>
  850.       <keyword>socket</keyword>
  851.       <keyword>socketpair</keyword>
  852.       <keyword>sort</keyword>
  853.       <keyword>splice</keyword>
  854.       <keyword>split</keyword>
  855.       <keyword>sprintf</keyword>
  856.       <keyword>sqrt</keyword>
  857.       <keyword>srand</keyword>
  858.       <keyword>stat</keyword>
  859.       <keyword>study</keyword>
  860.       <keyword>substr</keyword>
  861.       <keyword>symlink</keyword>
  862.       <keyword>syscall</keyword>
  863.       <keyword>sysread</keyword>
  864.       <keyword>sysseek</keyword>
  865.       <keyword>system</keyword>
  866.       <keyword>syswrite</keyword>
  867.       <keyword>telldir</keyword>
  868.       <keyword>tell</keyword>
  869.       <keyword>tied</keyword>
  870.       <keyword>tie</keyword>
  871.       <keyword>time</keyword>
  872.       <keyword>times</keyword>
  873.       <keyword>truncate</keyword>
  874.       <keyword>ucfirst</keyword>
  875.       <keyword>uc</keyword>
  876.       <keyword>umask</keyword>
  877.       <keyword>undef</keyword>
  878.       <keyword>unlink</keyword>
  879.       <keyword>unpack</keyword>
  880.       <keyword>unshift</keyword>
  881.       <keyword>untie</keyword>
  882.       <keyword>utime</keyword>
  883.       <keyword>values</keyword>
  884.       <keyword>vec</keyword>
  885.       <keyword>wait</keyword>
  886.       <keyword>waitpid</keyword>
  887.       <keyword>wantarray</keyword>
  888.       <keyword>warn</keyword>
  889.       <keyword>write</keyword>
  890.     </context>
  891.  
  892.     <!-- #### COMMENTS / POD / DATA ####################################### -->
  893.  
  894.     <!-- usual comments for perl are def:shell-style-comment -->
  895.     <!-- comment that must have a whitespace before (used in s{}{}, because
  896.          perl bugs if there is no space between '}' and '#') -->
  897.     <context id="asserted-comment" style-ref="comment" end-at-line-end="true">
  898.       <start>(?<![^\s])#</start>
  899.       <include><context ref="def:in-comment"/></include>
  900.     </context>
  901.  
  902.     <context id="line-directive" style-ref="line-directive">
  903.       <!-- see `man perlsyn` line 676 -->
  904.       <match extended="true">
  905.         ^\# \s*
  906.         (line \s+ (\d+)) \s*
  907.         (?:(\s"([^"]+)"|[^"]+))? \s*
  908.         $
  909.       </match>
  910.       <include>
  911.         <context sub-pattern="3" style-ref="string"/>
  912.       </include>
  913.     </context>
  914.  
  915.     <context id="in-pod">
  916.       <include>
  917.         <context ref="def:in-comment"/>
  918.         <context ref="pod-escape"/>
  919.       </include>
  920.     </context>
  921.  
  922.     <context id="pod-escape">
  923.       <include>
  924.         <context>
  925.           <start>[IBCLEFSXZ]<(?!<)</start><end>(?<!>)></end>
  926.           <include>
  927.             <context sub-pattern="0" where="start" style-ref="pod-escape"/>
  928.             <context sub-pattern="0" where="end" style-ref="pod-escape"/>
  929.             <context ref="in-pod"/>
  930.           </include>
  931.         </context>
  932.         <!-- doubled angle brackets ("<<" and ">>") may be used if and only if
  933.              there is whitespace right after the opening delimiter and
  934.              whitespace right before the closing delimiter! (`man perlpod`) -->
  935.         <context>
  936.           <start>[IBCLEFSXZ]<{2}\s</start><end>\s>{2}</end>
  937.           <include>
  938.             <context sub-pattern="0" where="start" style-ref="pod-escape"/>
  939.             <context sub-pattern="0" where="end" style-ref="pod-escape"/>
  940.             <context ref="in-pod"/>
  941.           </include>
  942.         </context>
  943.         <context>
  944.           <start>[IBCLEFSXZ]<{3}\s</start><end>\s>{3}</end>
  945.           <include>
  946.             <context sub-pattern="0" where="start" style-ref="pod-escape"/>
  947.             <context sub-pattern="0" where="end" style-ref="pod-escape"/>
  948.             <context ref="in-pod"/>
  949.           </include>
  950.         </context>
  951.         <context>
  952.           <start>[IBCLEFSXZ]<{4}\s</start><end>\s>{4}</end>
  953.           <include>
  954.             <context sub-pattern="0" where="start" style-ref="pod-escape"/>
  955.             <context sub-pattern="0" where="end" style-ref="pod-escape"/>
  956.             <context ref="in-pod"/>
  957.           </include>
  958.         </context>
  959.         <context>
  960.           <start>[IBCLEFSXZ]<{5}\s</start><end>\s>{5}</end>
  961.           <include>
  962.             <context sub-pattern="0" where="start" style-ref="pod-escape"/>
  963.             <context sub-pattern="0" where="end" style-ref="pod-escape"/>
  964.             <context ref="in-pod"/>
  965.           </include>
  966.         </context>
  967.         <context>
  968.           <start>[IBCLEFSXZ]<{6}\s</start><end>\s>{6}</end>
  969.           <include>
  970.             <context sub-pattern="0" where="start" style-ref="pod-escape"/>
  971.             <context sub-pattern="0" where="end" style-ref="pod-escape"/>
  972.             <context ref="in-pod"/>
  973.           </include>
  974.         </context>
  975.         <!-- one should be insane to put there more than 6 brackets -->
  976.       </include>
  977.     </context>
  978.  
  979.     <context id="pod-heading" end-at-line-end="true" style-inside="true" style-ref="pod-heading">
  980.       <start>^=(head[1-4])</start>
  981.       <include>
  982.         <context sub-pattern="1" where="start" style-ref="pod-keyword"/>
  983.         <context ref="in-pod"/>
  984.       </include>
  985.     </context>
  986.  
  987.     <context id="pod" style-ref="pod">
  988.       <start>^(?=(=[a-z]))</start>
  989.       <end>^=(cut)$</end>
  990.       <include>
  991.         <context sub-pattern="1" where="end" style-ref="pod-keyword"/>
  992.         <context ref="pod-heading"/>
  993.         <context>
  994.           <match>^=(pod|encoding|over|item|back)</match>
  995.           <include><context sub-pattern="1" style-ref="pod-keyword"/></include>
  996.         </context>
  997.         <context>
  998.           <start>^=(begin)\s+(.*)$</start>
  999.           <end>^=(end)\s+\%{1@start}$</end>
  1000.           <include>
  1001.             <context sub-pattern="1" where="start" style-ref="pod-keyword"/>
  1002.             <context sub-pattern="1" where="end" style-ref="pod-keyword"/>
  1003.             <context ref="pod"/>
  1004.           </include>
  1005.         </context>
  1006.         <context ref="in-pod"/>
  1007.       </include>
  1008.     </context>
  1009.  
  1010.     <context id="data" style-ref="comment">
  1011.       <start>__(DATA|END)__</start>
  1012.       <include>
  1013.         <context sub-pattern="0" where="start" style-ref="keyword"/>
  1014.       </include>
  1015.     </context>
  1016.   </definitions>
  1017. </language>
  1018.